package networkcontroller;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Class that stores network configuration - for future use
 * 
 * @author maciek
 * 
 */
public class NetworkConfiguration
{
	int			port	= 6543;
	InetAddress	multicastAddress;

	// Protected constructor is sufficient to suppress unauthorized calls to the
	// constructor
	protected NetworkConfiguration()
	{
		try
		{
			multicastAddress = Inet4Address.getByName("224.5.4.3");
		} catch (UnknownHostException e)
		{
			e.printStackTrace();
		}
	}

	/**
	 * SingletonHolder is loaded on the first execution of
	 * Singleton.getInstance() or the first access to SingletonHolder.INSTANCE,
	 * not before.
	 */
	private static class NetworkConfigurationHolder
	{
		private static final NetworkConfiguration	INSTANCE	= new NetworkConfiguration();
	}

	/**
	 * gets instance of network configuration
	 * 
	 * @return network configuration
	 */
	public static NetworkConfiguration getInstance()
	{
		return NetworkConfigurationHolder.INSTANCE;
	}

	/**
	 * get application port number
	 * 
	 * @return port number
	 */
	public int getPort()
	{
		return port;
	}

	/**
	 * get application multicast group address
	 * 
	 * @return multicast address
	 */
	public InetAddress getMulticastAddress()
	{
		return multicastAddress;
	}
}
